//
//  DCChengeBankView.m
//  Demo
//
//  Created by Kyle on 2023/1/5.
//

#import "DCChengeBankView.h"



@interface DCChengeBankView ()<UITextFieldDelegate>

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UITextField *textField;

@property (nonatomic, strong) UIImageView *rightImage;
@end
@implementation DCChengeBankView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self confiugreUI];
    }
    return self;
}

- (void)configureTitle:(NSString *)title {
    _titleLabel.text = title;
}

- (void)configureContent:(NSString *)content {
    _textField.text = content;

}

- (void)confiugreUI {
    _titleLabel = [UILabel new];
    _titleLabel.text = @"----";
    _titleLabel.textColor = [UIColor colorWithString:@"#1C221B"];
    _titleLabel.font = DCFont_PF_Regular(13);
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(24);
        make.top.mas_equalTo(20);
    }];
    
    UIView *whiteBG = [UIView new];
    whiteBG.layer.cornerRadius = 8;
    whiteBG.layer.masksToBounds = YES;
    whiteBG.layer.borderWidth = 1;
    whiteBG.layer.borderColor = [[UIColor colorWithString:@"#F7F7F7"] CGColor];
    [self addSubview:whiteBG];
    [whiteBG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(18);
        make.height.mas_equalTo(54);
        make.right.mas_equalTo(-18);
        make.top.mas_equalTo(_titleLabel.mas_bottom).mas_offset(10);
    }];
    
    _textField = [UITextField new];
    _textField.delegate = self;
    _textField.font = DCFont_PF_Medium(14);
    _textField.textColor = [UIColor colorWithString:@"#1C221B"];
    [whiteBG addSubview:_textField];
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.centerY.mas_equalTo(whiteBG);
        make.right.mas_equalTo(-35);
        make.height.mas_equalTo(40);
    }];
    
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    return self.canEdit;
}        // return NO to disallow editing.

- (void)textFieldDidEndEditing:(UITextField *)textField {
    if (self.delegate && [self.delegate respondsToSelector:@selector(endEditingWithText:)]) {
        [self.delegate endEditingWithText:textField.text];
    } 
}

@end
